package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MerchantOrderItem;
import com.rockcent.mall.lib.domain.enumclass.MerchantOrderMerchantRole;
import com.rockcent.mall.lib.domain.enumclass.SettlementStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by oyhk on 14-6-22.
 */
@Repository
public interface MerchantOrderItemRepository extends JpaRepository<MerchantOrderItem, Long>, JpaSpecificationExecutor, MerchantOrderItemRepositoryCustom {


    Long countByCustomerIdAndProductId(Long customerId, Long productId);

    List<MerchantOrderItem> findByMerchantOrderId(Long orderId);

    List<MerchantOrderItem> findByMerchantOrderNumIn(List<String> merchantOrderIdList);

    List<MerchantOrderItem> findByMerchantOrderIdAndMerchantId(Long id, Long merchantId);

    List<MerchantOrderItem> findByProductIdAndMerchantIdAndMallIdAndSettleStatusNot(Long productId, Long merchantId, Long mallId, SettlementStatus settleStatus);

    List<MerchantOrderItem> findByMerchantOrderNumAndMerchantIdAndMallId(String merchantOrderNum, Long merchantId, Long mallId);

    MerchantOrderItem findByMarketOrderNumAndMerchantRole(String marketOrderNum, MerchantOrderMerchantRole distributor);

    List<MerchantOrderItem> findByMerchantOrderNumInAndIsDelete(List<String> merchantOrderNumList, Whether no);

    List<MerchantOrderItem> findByProductIdAndMerchantIdAndMallId(Long productId, Long merchantId, Long mallId);

    List<MerchantOrderItem> findByMerchantOrderIdIn(List<Long> merchantOrderIdList);

    List<MerchantOrderItem> findByMarketOrderNumAndMerchantRoleAndIsDelete(String marketOrderNum, MerchantOrderMerchantRole distributor, Whether whether);

    MerchantOrderItem findByMarketOrderNumAndMerchantRoleAndProductId(String marketOrderNum, MerchantOrderMerchantRole distributor, Long id);
}
